# coding=utf8
from django.db import models
from datetime import datetime
from users.models import UserProfile, onceName
from treehole.models import secret


class chatRoom(models.Model):
    onceNameOne = models.ForeignKey(onceName, related_name="onceNameOne", verbose_name=u"聊天用户One")
    onceNameTwo = models.ForeignKey(onceName, related_name="onceNameTwo", verbose_name=u"聊天用户Two")
    secret = models.ForeignKey(secret, verbose_name=u"聊天秘密")
    isDelete = models.BooleanField(verbose_name=u"逻辑删除", default=False)

    class Meta:
        verbose_name = u"聊天房间"
        verbose_name_plural = verbose_name

    def __unicode__(self):
        return self.secret.title

    def __str__(self):
        return self.secret.title


class chatRecord(models.Model):
    chatRoom = models.ForeignKey(chatRoom, verbose_name=u"聊天房间")
    currentUser = models.ForeignKey(UserProfile, verbose_name=u"当前用户")
    content = models.TextField(verbose_name=u"聊天内容", default="")
    time = models.DateTimeField(default=datetime.now, verbose_name=u"添加时间")
    isDelete = models.BooleanField(verbose_name=u"逻辑删除", default=False)

    class Meta:
        verbose_name = u"聊天内容"
        verbose_name_plural = verbose_name

    def __unicode__(self):
        return self.content

    def __str__(self):
        return self.content
